package com.koron.device.controller;

import com.koron.bean.base.Response;
import com.koron.bean.query.PageQuery;
import com.koron.common.core.config.ThreadLocalContext;
import com.koron.device.bean.po.EquipmentDocument;
import com.koron.device.bean.query.EquipmentDocumentQuery;
import com.koron.device.service.EquipmentDocumentService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.koron.ebs.mybatis.ADOConnection;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 图档资料接口
 *
 */
@Api(tags = "图档资料")
@RequestMapping(value = "document")
@RestController
public class EquipmentDocumentController {

    @Autowired
    private EquipmentDocumentService equipmentDocumentService;


    public String getCurrDs (){
        return ThreadLocalContext.get().getCurrDs();
    }

    @PostMapping(value = "saveOrUpdateEquipmentDocument")
    @ApiOperation(value = "保存设备图档资料")
    public Response saveOrUpdateEquipmentDocument(@RequestBody List<EquipmentDocument> equipmentDocumentList){
        return ADOConnection.runTask(getCurrDs(), equipmentDocumentService, "saveEquipmentDocument", Response.class, equipmentDocumentList);
    }

    @GetMapping(value = "delete")
    @ApiOperation(value = "删除设备图档资料")
    public Response deleteEquipmentDocument(@RequestParam List<String> ids){
        return ADOConnection.runTask(getCurrDs(), equipmentDocumentService, "deleteEquipmentDocument", Response.class, ids);
    }

    @GetMapping(value = "queryList")
    @ApiOperation(value = "查询设备图档资料列表")
    public Response queryEquipmentDocumentList(PageQuery pageQuery, EquipmentDocumentQuery equipmentDocumentQuery){
        return ADOConnection.runTask(getCurrDs(), equipmentDocumentService, "queryEquipmentDocumentList", Response.class, pageQuery, equipmentDocumentQuery);
    }
}
